/*
*	create by  jack ,20210705
*	
*	描述  
*		  该文件提供了一套线程调用的接口，屏蔽具体实现细节,以达到应用程序可以在不同的平台上联合调试。
*   修改记录：[内容][作者][时间]
*	
*/
#ifndef _SANJI_OS_KLIST_H_
#define _SANJI_OS_KLIST_H_

#include "define_comm.h"


#ifdef __cplusplus
extern "C"{
#endif

struct klist_node{
	struct klist_node *prev;
	struct klist_node *next;
	sj_void *node;
};

struct klist{
	struct klist_node *prev;
	struct klist_node *next;
};

struct  klist_iter{
	struct klist		*i_klist;
	struct klist_node	*i_cur;
};

sj_void klist_init(struct klist *list);

sj_void klist_node_init(struct klist_node *list,sj_void *node);

sj_void* klist_node_get(struct klist_node *knode);

sj_void klist_add_tail(struct klist_node *n, struct klist *k);

sj_void klist_add_head(struct klist_node *n, struct klist *k);

sj_void klist_iter_init(struct klist *k, struct klist_iter *iter);

struct klist_node *klist_next(struct klist_iter *iter);

struct klist_node *klist_prev(struct klist_iter *iter);

sj_void klist_iter_exit(struct klist_iter *iter);

sj_bool klist_iter_is_head(struct klist_iter *iter);

#define KLIST_INIT(name) struct klist name={ &(name), &(name) }

#define KLIST_NODE_INIT(name , data) struct klist_node name={ &(name), &(name), data } 
	
#define KLIST_ITER_INIT(name,k) struct klist_iter name={ k,NULL }

#ifdef __cplusplus
}
#endif

#endif
